//package com.study;
//
//import org.apache.ibatis.io.Resources;
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.apache.ibatis.session.SqlSessionFactoryBuilder;
//import org.springframework.context.support.ClassPathXmlApplicationContext;
//
//import java.io.IOException;
//import java.io.InputStream;
//import java.sql.Connection;
//import java.sql.DriverManager;
//import java.sql.SQLException;
//
//public class DataSourceConnectionTest {
//    public static void main(String[] args) throws ClassNotFoundException, SQLException, IOException {
//        /*//1.加载驱动
//        Class.forName("com.mysql.jdbc.Driver");
//        //2.连接数据库
//        String url = "jdbc:mysql://localhost:3306/mybatis";
//        String user = "root";
//        String pwd = "root";
//        Connection connection = DriverManager.getConnection(url, user, pwd);
//        System.out.println(connection);*/
////        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext2.xml");
//////        Object connection = applicationContext.getBean("connection");
//////        System.out.println(connection);
////        Object date = applicationContext.getBean("date");
////        System.out.println(date);
//
//        /*//配置MyBatis的SqlSessionFactory方式
//        //加载mybatis核心配置文件，使用Spring静态工厂方式
//        InputStream in = Resources.getResourceAsStream("mybatis-config.xml");
//        //创建SqlSessionFactoryBuilder对象，使用Spring无参构造方式
//        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
//        //调用SqlSessionFactoryBuilder的build方法，使用Spring实例工厂方式
//        SqlSessionFactory sqlSessionFactory = builder.build(in);
//        System.out.println(sqlSessionFactory);*/
//        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext2.xml");
//        Object sqlSessionFactory = applicationContext.getBean("sqlSessionFactory");
//        System.out.println(sqlSessionFactory);
//
//    }
//}
